/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.StructuredActivities;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.Kernel.VisibilityKind;
import edu.pku.sei.modeler.model.uml.FundamentalActivities.ActivityNode;
import edu.pku.sei.modeler.model.uml.BasicActivities.ActivityEdge;
import edu.pku.sei.modeler.model.uml.Kernel.PackageableElement;
import edu.pku.sei.modeler.model.uml.Kernel.NamedElement;
import edu.pku.sei.modeler.model.uml.Kernel.NamedElement;
import edu.pku.sei.modeler.model.uml.Kernel.PackageImport;
import edu.pku.sei.modeler.model.uml.Kernel.ElementImport;
import edu.pku.sei.modeler.model.uml.Kernel.Constraint;
import edu.pku.sei.modeler.model.uml.Dependencies.Dependency;
import edu.pku.sei.modeler.model.uml.ExtraStructuredActivities.ExceptionHandler;
import edu.pku.sei.modeler.model.uml.BasicActivities.ActivityEdge;
import edu.pku.sei.modeler.model.uml.BasicActivities.ActivityEdge;
import edu.pku.sei.modeler.model.uml.Kernel.Classifier;
import edu.pku.sei.modeler.model.uml.Kernel.RedefinableElement;
import edu.pku.sei.modeler.model.uml.Kernel.Constraint;
import edu.pku.sei.modeler.model.uml.Kernel.Constraint;
import edu.pku.sei.modeler.model.uml.BasicActions.OutputPin;
import edu.pku.sei.modeler.model.uml.BasicActions.InputPin;

import edu.pku.sei.modeler.model.uml.FundamentalActivities.ActivityGroup;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class StructuredActivityNode extends ActivityGroup implements IStructuredActivityNode {
	// attributes
	
	protected boolean mustIsolate;
	
	
	
	protected String name;
	
	protected VisibilityKind visibility;
	
	protected String qualifiedName;
	
	protected boolean isLeaf;
	
	
	// references
	
	protected MetaTypedList containedNode;
	
	protected MetaTypedList containedEdge;
	
	
	
	protected MetaTypedList importedMember;
	
	protected MetaTypedList member;
	
	protected MetaTypedList ownedMember;
	
	protected MetaTypedList packageImport;
	
	protected MetaTypedList elementImport;
	
	protected MetaTypedList ownedRule;
	
	protected MetaTypedList supplierDependency;
	
	protected MetaTypedList protectedNode;
	
	protected MetaTypedList incoming;
	
	protected MetaTypedList outgoing;
	
	protected MetaTypedList redefinitionContext;
	
	protected MetaTypedList redefinedElement;
	
	protected MetaTypedList localPostcondition;
	
	protected MetaTypedList localPrecondition;
	
	protected MetaTypedList output;
	
	protected MetaTypedList input;
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "STRUCTUREDACTIVITYNODE_MUSTISOLATE",
			catalog = "Model",
			name = ModelPackage.STRUCTUREDACTIVITYNODE_MUSTISOLATE,
			setter = "setmustIsolate"
			)
	
	public boolean getMustIsolate() {
		return mustIsolate;
	}
	public void setMustIsolate(boolean newMustIsolate) {
		boolean oldmustIsolate = mustIsolate;
		mustIsolate = newMustIsolate;
		firePropertyChange(ModelPackage.STRUCTUREDACTIVITYNODE_MUSTISOLATE, oldmustIsolate, newMustIsolate);
	}
	
	@MethodProperty(
			id = "STRUCTUREDACTIVITYNODE_NAME",
			catalog = "Model",
			name = ModelPackage.NAMEDELEMENT_NAME,
			setter = "setname"
			)
	
	public String getName() {
		return name;
	}
	public void setName(String newName) {
		String oldname = name;
		name = newName;
		firePropertyChange(ModelPackage.NAMEDELEMENT_NAME, oldname, newName);
	}
	
	public VisibilityKind getVisibility() {
		return visibility;
	}
	public void setVisibility(VisibilityKind newVisibility) {
		VisibilityKind oldvisibility = visibility;
		visibility = newVisibility;
		firePropertyChange(ModelPackage.NAMEDELEMENT_VISIBILITY, oldvisibility, newVisibility);
	}
	
	@MethodProperty(
			id = "STRUCTUREDACTIVITYNODE_QUALIFIEDNAME",
			catalog = "Model",
			name = ModelPackage.NAMEDELEMENT_QUALIFIEDNAME,
			setter = "setqualifiedName"
			)
	
	public String getQualifiedName() {
		return qualifiedName;
	}
	public void setQualifiedName(String newQualifiedName) {
		String oldqualifiedName = qualifiedName;
		qualifiedName = newQualifiedName;
		firePropertyChange(ModelPackage.NAMEDELEMENT_QUALIFIEDNAME, oldqualifiedName, newQualifiedName);
	}
	
	@MethodProperty(
			id = "STRUCTUREDACTIVITYNODE_ISLEAF",
			catalog = "Model",
			name = ModelPackage.REDEFINABLEELEMENT_ISLEAF,
			setter = "setisLeaf"
			)
	
	public boolean getIsLeaf() {
		return isLeaf;
	}
	public void setIsLeaf(boolean newIsLeaf) {
		boolean oldisLeaf = isLeaf;
		isLeaf = newIsLeaf;
		firePropertyChange(ModelPackage.REDEFINABLEELEMENT_ISLEAF, oldisLeaf, newIsLeaf);
	}
	
	// getters for references
	
	public MetaTypedList getContainedNode() {
		if(containedNode == null) {
			containedNode = new MetaTypedList(ActivityNode.class, this, ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDNODE);
		}
		return containedNode;
	}
	
	public MetaTypedList getContainedEdge() {
		if(containedEdge == null) {
			containedEdge = new MetaTypedList(ActivityEdge.class, this, ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDEDGE);
		}
		return containedEdge;
	}
	
	public MetaTypedList getImportedMember() {
		if(importedMember == null) {
			importedMember = new MetaTypedList(PackageableElement.class, this, ModelPackage.NAMESPACE_IMPORTEDMEMBER);
		}
		return importedMember;
	}
	
	public MetaTypedList getMember() {
		if(member == null) {
			member = new MetaTypedList(NamedElement.class, this, ModelPackage.NAMESPACE_MEMBER);
		}
		return member;
	}
	
	public MetaTypedList getOwnedMember() {
		if(ownedMember == null) {
			ownedMember = new MetaTypedList(NamedElement.class, this, ModelPackage.NAMESPACE_OWNEDMEMBER);
		}
		return ownedMember;
	}
	
	public MetaTypedList getPackageImport() {
		if(packageImport == null) {
			packageImport = new MetaTypedList(PackageImport.class, this, ModelPackage.NAMESPACE_PACKAGEIMPORT);
		}
		return packageImport;
	}
	
	public MetaTypedList getElementImport() {
		if(elementImport == null) {
			elementImport = new MetaTypedList(ElementImport.class, this, ModelPackage.NAMESPACE_ELEMENTIMPORT);
		}
		return elementImport;
	}
	
	public MetaTypedList getOwnedRule() {
		if(ownedRule == null) {
			ownedRule = new MetaTypedList(Constraint.class, this, ModelPackage.NAMESPACE_OWNEDRULE);
		}
		return ownedRule;
	}
	
	public MetaTypedList getSupplierDependency() {
		if(supplierDependency == null) {
			supplierDependency = new MetaTypedList(Dependency.class, this, ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY);
		}
		return supplierDependency;
	}
	
	public MetaTypedList getProtectedNode() {
		if(protectedNode == null) {
			protectedNode = new MetaTypedList(ExceptionHandler.class, this, ModelPackage.EXECUTABLENODE_PROTECTEDNODE);
		}
		return protectedNode;
	}
	
	public MetaTypedList getIncoming() {
		if(incoming == null) {
			incoming = new MetaTypedList(ActivityEdge.class, this, ModelPackage.ACTIVITYNODE_INCOMING);
		}
		return incoming;
	}
	
	public MetaTypedList getOutgoing() {
		if(outgoing == null) {
			outgoing = new MetaTypedList(ActivityEdge.class, this, ModelPackage.ACTIVITYNODE_OUTGOING);
		}
		return outgoing;
	}
	
	public MetaTypedList getRedefinitionContext() {
		if(redefinitionContext == null) {
			redefinitionContext = new MetaTypedList(Classifier.class, this, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT);
		}
		return redefinitionContext;
	}
	
	public MetaTypedList getRedefinedElement() {
		if(redefinedElement == null) {
			redefinedElement = new MetaTypedList(RedefinableElement.class, this, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT);
		}
		return redefinedElement;
	}
	
	public MetaTypedList getLocalPostcondition() {
		if(localPostcondition == null) {
			localPostcondition = new MetaTypedList(Constraint.class, this, ModelPackage.ACTION_LOCALPOSTCONDITION);
		}
		return localPostcondition;
	}
	
	public MetaTypedList getLocalPrecondition() {
		if(localPrecondition == null) {
			localPrecondition = new MetaTypedList(Constraint.class, this, ModelPackage.ACTION_LOCALPRECONDITION);
		}
		return localPrecondition;
	}
	
	public MetaTypedList getOutput() {
		if(output == null) {
			output = new MetaTypedList(OutputPin.class, this, ModelPackage.ACTION_OUTPUT);
		}
		return output;
	}
	
	public MetaTypedList getInput() {
		if(input == null) {
			input = new MetaTypedList(InputPin.class, this, ModelPackage.ACTION_INPUT);
		}
		return input;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.STRUCTUREDACTIVITYNODE_MUSTISOLATE, mustIsolate);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.NAMEDELEMENT_NAME, name);
		
		XMLUtility.xmlInstance.serializeNode(root, ModelPackage.NAMEDELEMENT_VISIBILITY, visibility);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.NAMEDELEMENT_QUALIFIEDNAME, qualifiedName);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.REDEFINABLEELEMENT_ISLEAF, isLeaf);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDNODE, containedNode);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDEDGE, containedEdge);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.NAMESPACE_IMPORTEDMEMBER, importedMember);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.NAMESPACE_MEMBER, member);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.NAMESPACE_OWNEDMEMBER, ownedMember);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.NAMESPACE_PACKAGEIMPORT, packageImport);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.NAMESPACE_ELEMENTIMPORT, elementImport);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.NAMESPACE_OWNEDRULE, ownedRule);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY, supplierDependency);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.EXECUTABLENODE_PROTECTEDNODE, protectedNode);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTIVITYNODE_INCOMING, incoming);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTIVITYNODE_OUTGOING, outgoing);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT, redefinitionContext);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT, redefinedElement);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTION_LOCALPOSTCONDITION, localPostcondition);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTION_LOCALPRECONDITION, localPrecondition);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ACTION_OUTPUT, output);
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ACTION_INPUT, input);
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		mustIsolate = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.STRUCTUREDACTIVITYNODE_MUSTISOLATE);
		
		name = XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.NAMEDELEMENT_NAME);
		
		visibility = (VisibilityKind)XMLUtility.xmlInstance.deSerializeNode(root, ModelPackage.NAMEDELEMENT_VISIBILITY, this);
		
		qualifiedName = XMLUtility.xmlInstance.deSerializeString(root, ModelPackage.NAMEDELEMENT_QUALIFIEDNAME);
		
		isLeaf = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.REDEFINABLEELEMENT_ISLEAF);
		
		// references
		
		this.getContainedNode().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDNODE, this));
		
		this.getContainedEdge().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDEDGE, this));
		
		this.getImportedMember().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.NAMESPACE_IMPORTEDMEMBER, this));
		
		this.getMember().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.NAMESPACE_MEMBER, this));
		
		this.getOwnedMember().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.NAMESPACE_OWNEDMEMBER));
		
		this.getPackageImport().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.NAMESPACE_PACKAGEIMPORT));
		
		this.getElementImport().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.NAMESPACE_ELEMENTIMPORT));
		
		this.getOwnedRule().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.NAMESPACE_OWNEDRULE));
		
		this.getSupplierDependency().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY, this));
		
		this.getProtectedNode().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.EXECUTABLENODE_PROTECTEDNODE, this));
		
		this.getIncoming().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTIVITYNODE_INCOMING, this));
		
		this.getOutgoing().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTIVITYNODE_OUTGOING, this));
		
		this.getRedefinitionContext().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT, this));
		
		this.getRedefinedElement().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT, this));
		
		this.getLocalPostcondition().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTION_LOCALPOSTCONDITION, this));
		
		this.getLocalPrecondition().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTION_LOCALPRECONDITION, this));
		
		this.getOutput().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ACTION_OUTPUT));
		
		this.getInput().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ACTION_INPUT));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		else if(ModelPackage.NAMEDELEMENT_VISIBILITY.equals(featureID)) {
			visibility = (VisibilityKind)value;
		}
		
		// references
		
		else if(ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDNODE.equals(featureID)) {
			getContainedNode().add(value);
		}
		
		else if(ModelPackage.STRUCTUREDACTIVITYNODE_CONTAINEDEDGE.equals(featureID)) {
			getContainedEdge().add(value);
		}
		
		else if(ModelPackage.NAMESPACE_IMPORTEDMEMBER.equals(featureID)) {
			getImportedMember().add(value);
		}
		
		else if(ModelPackage.NAMESPACE_MEMBER.equals(featureID)) {
			getMember().add(value);
		}
		
		else if(ModelPackage.NAMEDELEMENT_SUPPLIERDEPENDENCY.equals(featureID)) {
			getSupplierDependency().add(value);
		}
		
		else if(ModelPackage.EXECUTABLENODE_PROTECTEDNODE.equals(featureID)) {
			getProtectedNode().add(value);
		}
		
		else if(ModelPackage.ACTIVITYNODE_INCOMING.equals(featureID)) {
			getIncoming().add(value);
		}
		
		else if(ModelPackage.ACTIVITYNODE_OUTGOING.equals(featureID)) {
			getOutgoing().add(value);
		}
		
		else if(ModelPackage.REDEFINABLEELEMENT_REDEFINITIONCONTEXT.equals(featureID)) {
			getRedefinitionContext().add(value);
		}
		
		else if(ModelPackage.REDEFINABLEELEMENT_REDEFINEDELEMENT.equals(featureID)) {
			getRedefinedElement().add(value);
		}
		
		else if(ModelPackage.ACTION_LOCALPOSTCONDITION.equals(featureID)) {
			getLocalPostcondition().add(value);
		}
		
		else if(ModelPackage.ACTION_LOCALPRECONDITION.equals(featureID)) {
			getLocalPrecondition().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 